{"ast":null,"code":"var _jsxFileName = \"/data/messenger.client/src/components/Dialog/index.tsx\",\n  _s = $RefreshSig$();\nimport React from 'react';\nimport { DialogInput, Name, UserStatus } from \"../\";\nimport { Context } from \"../../index\";\nimport { Messages } from \"../../containers\";\nimport { observer } from \"mobx-react-lite\";\nimport './Dialog.scss';\nimport { getOtherUserForNotMultiChat } from \"../../utils/Membership\";\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nconst Dialog = () => {\n  _s();\n  var _store$currentDialog$, _store$currentDialog$2;\n  const {\n    store\n  } = React.useContext(Context);\n  const [chatId, setChatId] = React.useState(null);\n  const [otherUser, setOtherUser] = React.useState();\n  React.useEffect(() => {\n    if (store.viewedDialogId) {\n      setChatId(store.viewedDialogId);\n    }\n  }, [store.viewedDialogId]);\n  React.useEffect(() => {\n    if (store.currentDialog && !store.currentDialog.multiChat && store.currentDialog.membership && store.currentDialog.membership.items.length > 0) {\n      setOtherUser(getOtherUserForNotMultiChat(store, store.currentDialog.membership));\n    }\n  }, [store, store.currentDialog]);\n  return /*#__PURE__*/_jsxDEV(\"div\", {\n    className: \"messenger__dialog\",\n    children: [store.getViewedDialogId() && /*#__PURE__*/_jsxDEV(\"div\", {\n      className: \"messenger__dialog-header\",\n      children: [/*#__PURE__*/_jsxDEV(\"div\", {}, void 0, false, {\n        fileName: _jsxFileName,\n        lineNumber: 38,\n        columnNumber: 21\n      }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n        className: \"messenger__dialog-header-info\",\n        children: [/*#__PURE__*/_jsxDEV(\"p\", {\n          className: \"messenger__dialog-header-name\",\n          children: /*#__PURE__*/_jsxDEV(Name, {\n            user: otherUser,\n            chatName: store.currentDialog.name,\n            multiChat: store.currentDialog.multiChat\n          }, void 0, false, {\n            fileName: _jsxFileName,\n            lineNumber: 41,\n            columnNumber: 29\n          }, this)\n        }, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 40,\n          columnNumber: 25\n        }, this), !store.getCurrentDialog().multiChat && /*#__PURE__*/_jsxDEV(\"div\", {\n          className: \"messenger__dialog-header-status\",\n          children: /*#__PURE__*/_jsxDEV(UserStatus, {\n            status: true\n          }, void 0, false, {\n            fileName: _jsxFileName,\n            lineNumber: 46,\n            columnNumber: 33\n          }, this)\n        }, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 45,\n          columnNumber: 29\n        }, this) || /*#__PURE__*/_jsxDEV(\"div\", {\n          className: \"messenger__dialog-header-countMemberships\",\n          children: ((_store$currentDialog$ = store.currentDialog.membership) === null || _store$currentDialog$ === void 0 ? void 0 : _store$currentDialog$.items) && /*#__PURE__*/_jsxDEV(\"span\", {\n            children: `Участников в диалоге: ${Object.keys((_store$currentDialog$2 = store.currentDialog.membership) === null || _store$currentDialog$2 === void 0 ? void 0 : _store$currentDialog$2.items).length}`\n          }, void 0, false, {\n            fileName: _jsxFileName,\n            lineNumber: 51,\n            columnNumber: 37\n          }, this)\n        }, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 49,\n          columnNumber: 29\n        }, this)]\n      }, void 0, true, {\n        fileName: _jsxFileName,\n        lineNumber: 39,\n        columnNumber: 21\n      }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n        className: \"messenger__dialog-header-more\"\n      }, void 0, false, {\n        fileName: _jsxFileName,\n        lineNumber: 58,\n        columnNumber: 21\n      }, this)]\n    }, void 0, true, {\n      fileName: _jsxFileName,\n      lineNumber: 37,\n      columnNumber: 17\n    }, this), /*#__PURE__*/_jsxDEV(\"div\", {\n      className: \"messenger__dialog-messages\",\n      children: /*#__PURE__*/_jsxDEV(Messages, {}, void 0, false, {\n        fileName: _jsxFileName,\n        lineNumber: 62,\n        columnNumber: 17\n      }, this)\n    }, void 0, false, {\n      fileName: _jsxFileName,\n      lineNumber: 61,\n      columnNumber: 13\n    }, this), store.getViewedDialogId() && /*#__PURE__*/_jsxDEV(\"div\", {\n      className: \"messenger__dialog-input\",\n      children: /*#__PURE__*/_jsxDEV(DialogInput, {\n        chatId: chatId && chatId\n      }, void 0, false, {\n        fileName: _jsxFileName,\n        lineNumber: 66,\n        columnNumber: 21\n      }, this)\n    }, void 0, false, {\n      fileName: _jsxFileName,\n      lineNumber: 65,\n      columnNumber: 17\n    }, this)]\n  }, void 0, true, {\n    fileName: _jsxFileName,\n    lineNumber: 35,\n    columnNumber: 9\n  }, this);\n};\n_s(Dialog, \"Q7GQ1r9hUhecWFCJn8AW31Qs0BQ=\");\n_c = Dialog;\nexport default _c2 = observer(Dialog);\nvar _c, _c2;\n$RefreshReg$(_c, \"Dialog\");\n$RefreshReg$(_c2, \"%default%\");","map":{"version":3,"names":["React","DialogInput","Name","UserStatus","Context","Messages","observer","getOtherUserForNotMultiChat","Dialog","store","useContext","chatId","setChatId","useState","otherUser","setOtherUser","useEffect","viewedDialogId","currentDialog","multiChat","membership","items","length","getViewedDialogId","name","getCurrentDialog","Object","keys"],"sources":["/data/messenger.client/src/components/Dialog/index.tsx"],"sourcesContent":["import React from 'react';\nimport {DialogInput, Name, UserStatus} from \"../\";\nimport {Context} from \"../../index\";\nimport {Messages} from \"../../containers\";\nimport {observer} from \"mobx-react-lite\";\nimport {UserListItem} from \"../../models/response/UserListItem\";\nimport './Dialog.scss';\nimport {getOtherUserForNotMultiChat} from \"../../utils/Membership\";\n\nconst Dialog = () => {\n    const {store} = React.useContext(Context);\n    const [chatId, setChatId] = React.useState<number | null>(null);\n    const [otherUser, setOtherUser] = React.useState<UserListItem>();\n\n    React.useEffect(() => {\n        if (store.viewedDialogId!) {\n            setChatId(store.viewedDialogId);\n        }\n    }, [store.viewedDialogId]);\n\n    React.useEffect(() => {\n\n        if (store.currentDialog! &&\n            !store.currentDialog.multiChat &&\n            store.currentDialog.membership &&\n            store.currentDialog.membership.items.length > 0\n        ) {\n            setOtherUser(\n                getOtherUserForNotMultiChat(store, store.currentDialog.membership)\n            );\n        }\n    }, [store, store.currentDialog]);\n\n    return (\n        <div className=\"messenger__dialog\">\n            {store.getViewedDialogId()! && (\n                <div className=\"messenger__dialog-header\">\n                    <div/>\n                    <div className=\"messenger__dialog-header-info\">\n                        <p className=\"messenger__dialog-header-name\">\n                            <Name user={otherUser} chatName={store.currentDialog.name} multiChat={store.currentDialog.multiChat} />\n                        </p>\n                        {(\n                            (!store.getCurrentDialog().multiChat) && (\n                            <div className=\"messenger__dialog-header-status\">\n                                <UserStatus status={true} />\n                            </div>\n                        ) || (\n                            <div className=\"messenger__dialog-header-countMemberships\">\n                                {store.currentDialog.membership?.items &&\n                                    <span>\n                                        {`Участников в диалоге: ${Object.keys(store.currentDialog.membership?.items).length}`}\n                                    </span>\n                                }\n                            </div>\n                        ))}\n                    </div>\n                    <button className=\"messenger__dialog-header-more\" />\n                </div>\n            )}\n            <div className=\"messenger__dialog-messages\">\n                <Messages />\n            </div>\n            {store.getViewedDialogId()! && (\n                <div className=\"messenger__dialog-input\">\n                    <DialogInput chatId={chatId! && chatId} />\n                </div>\n            )}\n        </div>\n    );\n}\n\nexport default observer(Dialog);"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAQC,WAAW,EAAEC,IAAI,EAAEC,UAAU,QAAO,KAAK;AACjD,SAAQC,OAAO,QAAO,aAAa;AACnC,SAAQC,QAAQ,QAAO,kBAAkB;AACzC,SAAQC,QAAQ,QAAO,iBAAiB;AAExC,OAAO,eAAe;AACtB,SAAQC,2BAA2B,QAAO,wBAAwB;AAAC;AAEnE,MAAMC,MAAM,GAAG,MAAM;EAAA;EAAA;EACjB,MAAM;IAACC;EAAK,CAAC,GAAGT,KAAK,CAACU,UAAU,CAACN,OAAO,CAAC;EACzC,MAAM,CAACO,MAAM,EAAEC,SAAS,CAAC,GAAGZ,KAAK,CAACa,QAAQ,CAAgB,IAAI,CAAC;EAC/D,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGf,KAAK,CAACa,QAAQ,EAAgB;EAEhEb,KAAK,CAACgB,SAAS,CAAC,MAAM;IAClB,IAAIP,KAAK,CAACQ,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